
package com.ylc.chat.server;

import com.ylc.chat.entity.User;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * @Author: ylc
 * @Description:服务端数据缓存
 */
public class ServerDataBuffer {
    // 服务器端套接字
    public static ServerSocket serverSocket;
    //在线用户的IO Map
    public static Map<String, OnlineClientIOCache> onlineUserIOCacheMap;
    //在线用户Map
    public static Map<String, User> onlineUsersMap;
    //服务器配置参数属性集
    public static Properties configProp;


    static{
        // 初始化
        onlineUserIOCacheMap = new ConcurrentSkipListMap<String,OnlineClientIOCache>();
        onlineUsersMap = new ConcurrentSkipListMap<String, User>();
        configProp = new Properties();

        // 加载服务器配置文件
        try {
            configProp.load(Thread.currentThread()
                    .getContextClassLoader()
                    .getResourceAsStream("serverconfig.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
